import os
#sed -i "s/must wait\.\")/\0\n    exit(1)/g" autocommit.py
def get_dirs():
    dirs = os.listdir(".")
    return [x for x in dirs if "james" in x and "deutschland" in x]

def get_subdirs(dirs):
    candidates = []
    for x in dirs:
        subdirs = os.listdir(x)
        subdirs = ["/".join([x,y]) for y in subdirs]
        subdirs = [y for y in subdirs if os.path.isdir(y)]
        candidates += subdirs
    return candidates

dirs = get_dirs()
subdirs = get_subdirs(dirs)
with open("change_autocommit.sh", "w+") as f:
    for x in subdirs:
        f.write("sed -i \"s/must wait\\.\\\")/\\0\\n    exit(1)/g\" {}/autocommit/autocommit.py\n".format(x))
